import UIKit

//嵌套类型 在枚举，类和结构体中定义支持嵌套类型
struct BlackjackCard {
    enum Suit: Character {
        case Spades = "♠"
        case Hearts = "❤"
        case Diamond = "💎"
        case Club = "♣"
    }
    
    enum Rank:Int {
    case Two = 2, Three, Four, Five, Six, Seven, Eight, Nine, Ten
        case Jack, Queue, King, Ace
        struct Values {
            let firtst:Int, second:Int?
        }
        
        var values:Values {
            switch self {
            case .Ace:
                return Values(firtst: 1, second: 11)
            case .Jack, .Queue, .King:
                return Values(firtst: 10, second: nil)
            default:
                return Values(firtst: self.rawValue, second: nil)
            }
        }
    }
    
    let rank:Rank, suit:Suit
    var description:String {
        var output = "suit is \(suit.rawValue)"
        output += " value is \(rank.values.firtst)"
        if let second = rank.values.second {
            output += " or \(second)"
        }
        return output
    }
}

let theAceOfSpade = BlackjackCard(rank: .Ace, suit: .Spades)
print("the ace of spades: \(theAceOfSpade.description)")
let hearsSymbol = BlackjackCard.Suit.Hearts.rawValue

BlackjackCard.Rank.King.rawValue



